﻿using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LMNumberList : EventManager
{
    public GameObject grid, DesPanel;
    public Button ret, FindOthers, FindItemPanelRet;
    public Text all, now;
    public int clubId;
    public InputField ToFindId;
    private LmNumList FindIdList;
    public GameObject FinItem, FindItemPanel, FindItemGrid;
    private void Awake()
    {
        ret.onClick.AddListener(delegate
        {
            Destroy(this.gameObject);
        });
        FindOthers.onClick.AddListener(FindOther);
        FindItemPanelRet.onClick.AddListener(delegate
        {
            FindItemPanel.SetActive(false);
            if (FindItemGrid.transform.GetChildCount() != 0)
            {
                Destroy(FindItemGrid.transform.GetChild(0).gameObject);
            }
        });
    }
    public override void InformationSetting()
    {
    }
    public void SetList(LmNumList cr, string clubid)
    {
        clubId = int.Parse(clubid);
        FindIdList = cr;
        all.text = cr.numPeople.ToString();
        now.text = cr.nowPeople.ToString();
        if (cr.LmNumberlist == null)
        {
            return;
        }
        grid.transform.GetComponentsInChildren<OneP.InfinityScrollView.InfinityScrollView>()[0].Setup(cr.LmNumberlist.Count);
    }
    public void ExitClub()
    {
        Debug.Log("ExitClub");
        //直接挂载button
        //GameData.GetInstance().userID
        MessageManager.GetInstance().SendMsg7121(int.Parse(GameData.GetInstance().userID), clubId);
    }
    public void Despanel()
    {
        DesPanel.SetActive(false);//直接挂载button//
    }
    public void ShowDespanel()
    {
        DesPanel.SetActive(true);//直接挂载button
    }
    public void FindOther()
    {
        if (ToFindId.text != null && ToFindId.text != "")
        {
            for (int i = 0; i < FindIdList.LmNumberlist.Count; i++)
            {
                if (int.Parse(ToFindId.text) == FindIdList.LmNumberlist[i].Id)
                {
                    FindItemPanel.SetActive(true);
                    GameObject items = Instantiate(FinItem);
                    items.transform.SetParent(FindItemGrid.transform);
                    items.transform.localPosition = Vector3.zero;
                    items.transform.localScale = Vector3.one;
                    if (FindIdList.LmNumberlist[i].Level == 0)
                    {
                        items.transform.GetChild(1).GetComponent<Text>().text = "会员";
                    }
                    else if (FindIdList.LmNumberlist[i].Level == 1)
                    {
                        items.transform.GetChild(1).GetComponent<Text>().text = "管理";
                    }
                    else if (FindIdList.LmNumberlist[i].Level == 2)
                    {
                        items.transform.GetChild(1).GetComponent<Text>().text = "盟主";
                    }
                    if (FindIdList.LmNumberlist[i].Online == 1)
                    {
                        items.transform.GetChild(2).GetComponent<Text>().color = new Color(200 / 255f, 183 / 255f, 234 / 255f);
                        items.transform.GetChild(3).GetComponent<Text>().color = new Color(200 / 255f, 183 / 255f, 234 / 255f);
                        items.transform.GetChild(4).GetComponent<Text>().color = new Color(200 / 255f, 183 / 255f, 234 / 255f);
                        items.transform.GetChild(1).GetComponent<Text>().color = new Color(200 / 255f, 183 / 255f, 234 / 255f);
                    }
                    else
                    {
                        items.transform.GetChild(1).GetComponent<Text>().color = new Color(116 / 255f, 112 / 255f, 124 / 255f);
                        items.transform.GetChild(2).GetComponent<Text>().color = new Color(116 / 255f, 112 / 255f, 124 / 255f);
                        items.transform.GetChild(3).GetComponent<Text>().color = new Color(116 / 255f, 112 / 255f, 124 / 255f);
                        items.transform.GetChild(4).GetComponent<Text>().color = new Color(116 / 255f, 112 / 255f, 124 / 255f);
                    }
                    items.transform.GetChild(2).GetComponent<Text>().text = FindIdList.LmNumberlist[i].Username;
                    items.transform.GetChild(3).GetComponent<Text>().text = FindIdList.LmNumberlist[i].Id.ToString();
                    items.transform.GetChild(4).GetComponent<Text>().text = FindIdList.LmNumberlist[i].Score.ToString();
                    i = FindIdList.LmNumberlist.Count;
                }
            }
        }
    }
}

